package com.epoint.androidphone.mobileoa.service;


import com.epoint.androidphone.R;
import com.epoint.androidphone.mobileoa.application.FrameParam;
import com.epoint.androidphone.mobileoa.service.mqtt.MQTTV2Util;
import com.ibm.mqtt.MqttClient;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;

/**
 * @author liyc
 * @time 2013-5-15 下午7:11:51
 * @annomation 
 */
public class MainService extends Service {

	public static String ServiceName = "EpointMainService";
	public static boolean isCheckTreadRun = true;
	FrameParam fp;
	MqttClient mqttClient;
	@Override
	public IBinder onBind(Intent arg0) {
		return null;
	}

	@Override
	public void onCreate() {
		super.onCreate();
		fp = (FrameParam) getApplication();
		System.out.println("Service_OnCreate");
		if(getString(R.string.message_push_enable).equals("1")){
			new Thread(new Runnable() {

				@Override
				public void run() {
					new  MQTTV2Util().MQTT_Connnect(MainService.this);
				}
			}).start();
		}

		new Thread(new Runnable() {

			@Override
			public void run() {

				while(isCheckTreadRun){
					try {
						Thread.sleep(5000);
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
					if(fp.getIsLogin()==1){
						System.out.println("监控线程");

					}
				}
			}
		}).start();
	}


}
